package demo.xlj.yuyi.studentapp.utils;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.Toast;

import es.dmoral.toasty.Toasty;


/**
 * 作者：项路俊 on 2018/2/24 0024
 * 邮箱：ThanksForCode@gmail.com
 * 介绍：Toasty的进一步封装
 */

public class ToastUtil {

    //错误的信息提示
    public static void error(Context context, String info, boolean time, boolean tipIcon) {
        if (time) {
            Toasty.error(context, info, Toast.LENGTH_SHORT, tipIcon).show();
        } else {
            Toasty.error(context, info, Toast.LENGTH_LONG, tipIcon).show();
        }
    }

    //成功的信息提示
    public static void success(Context context, String info, boolean time, boolean tipIcon) {
        if (time) {
            Toasty.success(context, info, Toast.LENGTH_SHORT, tipIcon).show();
        } else {
            Toasty.success(context, info, Toast.LENGTH_LONG, tipIcon).show();
        }
    }

    //提示信息
    public static void info(Context context, String info, boolean time, boolean tipIcon) {

        if (time) {
            Toasty.info(context, info, Toast.LENGTH_SHORT, tipIcon).show();
        } else {
            Toasty.info(context, info, Toast.LENGTH_LONG, tipIcon).show();
        }
    }

    //警告的信息提示
    public static void warning(Context context, String info, boolean time, boolean tipIcon) {

        if (time) {
            Toasty.warning(context, info, Toast.LENGTH_SHORT, tipIcon).show();
        } else {
            Toasty.warning(context, info, Toast.LENGTH_LONG, tipIcon).show();
        }
    }

    //正常的信息提示
    public static void normal(Context context, String info, boolean time, Drawable pic) {

        if (time) {
            Toasty.normal(context, info, Toast.LENGTH_SHORT, pic).show();
        } else {
            Toasty.normal(context, info, Toast.LENGTH_LONG, pic).show();
        }
    }

    //自定义的信息提示
    public static void custom(Context context, String info, int duration, Drawable pic, int textColor, boolean time, boolean tipIcon) {

        if (time) {
            Toasty.custom(context, info, pic, textColor, Toast.LENGTH_SHORT, tipIcon).show();
        } else {
            Toasty.custom(context, info, pic, textColor, Toast.LENGTH_LONG, tipIcon).show();
        }
    }

}
